﻿<UserControl x:Class="ResourceBlender.Express.TranslationInput"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender.Express"
    xmlns:converters="clr-namespace:ResourceBlender.Express.Converters"
    xmlns:validators="clr-namespace:ResourceBlender.Express.Validators"
    DataContext="{Binding RelativeSource={RelativeSource Self}}"
    Height="Auto" Width="Auto">
    <UserControl.Resources>
        <ResourceDictionary>
            <converters:LanguageCodeConverter x:Uid="converters:LanguageCodeConverter_1" x:Key="LanguageCodeConverter" />
            <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
            <Style TargetType="{x:Type TextBlock}">
                <Setter Property="Margin" Value="0,2,8,1" />
            </Style>
        </ResourceDictionary>
    </UserControl.Resources>
    <Border BorderBrush="{StaticResource GroupBoxBorderBrush}" BorderThickness="1" CornerRadius="2">
        <Grid Margin="5,2,5,2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" MinWidth="140" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="16" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <TextBlock x:Name="lblEnglishName" Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="0,4,1,4" /><!-- text set from code-behind -->
            <TextBox x:Name="txtTranslation" Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Path=Translation.Translation,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" />
            <ToggleButton x:Name="btnToggleEdit" Grid.Row="0" Grid.Column="3" MinHeight="10" MinWidth="10" VerticalAlignment="Top"
                        Style="{StaticResource GroupBoxExpanderToggleButtonStyle}" Margin="1,4,0,4"
                        IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, ElementName=EditControls}" />
            <Expander x:Name="EditControls" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" IsExpanded="false" Style="{StaticResource ButtonlessExpander}">
                <StackPanel>
                    <WrapPanel Orientation="Horizontal" HorizontalAlignment="Right">
                        <loc:ImageButton x:Name="btnFullEditorTranslation" Image="Resources/images/resource_expand_16.png" ShowText="False" ToolTip="Open the full editor for this translation" Margin="1"
                               Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtTranslation}" />
                        <loc:ImageButton x:Name="btnFindSimilar" Image="Resources/images/search_16.png" ShowText="False" Margin="1"
                               Command="loc:ResourceBlenderCommands.FindSimilar" CommandTarget="{Binding ElementName=txtTranslation}" CommandParameter="{Binding Translation.LanguageCode}"
                                ToolTip="{Binding Path=EnglishName,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}}}" />
                        <loc:ImageButton x:Name="btnWordNet" Image="pack://application:,,,/WordNet/Service.ico" ShowText="False" Margin="1" Width="24" Height="24"
                               Command="loc:ResourceBlenderCommands.WordNetLookup" CommandTarget="{Binding ElementName=txtTranslation}"
                               Visibility="{Binding Path=ShowWordNet,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource BoolToVisibilityConverter}}" /><!-- ToolTip from code-behind -->
                        <loc:ImageButton x:Name="btnGoogleTranslate" Image="/ResourceBlender.Core;Component/GoogleTranslate/Service.ico" ShowText="False" Margin="1" Width="24" Height="24"
                               Command="loc:ResourceBlenderCommands.AutoTranslate" CommandTarget="{Binding ElementName=txtTranslation}" CommandParameter="{Binding Translation.LanguageCode}" 
                               Visibility="{Binding Path=ShowGoogleTranslate,RelativeSource={RelativeSource FindAncestor,AncestorType={x:Type UserControl}},Converter={StaticResource BoolToVisibilityConverter}}" /><!-- ToolTip from code-behind -->
                    </WrapPanel> 
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>
                        
                        <TextBlock Grid.Row="0" Grid.Column="0" VerticalAlignment="Top" Margin="0,4,1,4">Translator Comment</TextBlock>
                        <TextBox x:Name="txtComment" Grid.Row="0" Grid.Column="1" Text="{Binding Path=Translation.Comment,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" />
                        <loc:ImageButton x:Name="btnFullEditorComment" Grid.Row="0" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Open the full editor for the translator's comment" Margin="1,1,0,1" VerticalAlignment="Top"
                               Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtComment}" />
                    </Grid>
                </StackPanel>
            </Expander>
        </Grid>
    </Border>
</UserControl>
